<template>
    <el-row>
        <el-col :offset="7">
            <el-steps :space="200" :active="2" align-center="false" finish-status="success">
                <el-step title="配置基本信息"></el-step>
                <el-step title="配置合同模板"></el-step>
                <el-step title="配置申请材料"></el-step>
            </el-steps>
        </el-col>
        <el-row></el-row><el-row></el-row>
        <el-row>
            <el-col :span="8" :offset="9" class="el1">
                <el-form ref="form" label-width="80px" style="float:left">

                    <el-form-item label="产品名称">
                        <el-input v-model="productName"></el-input>
                    </el-form-item>

                    <el-form-item label="产品ID">
                        <el-input v-model="template.productId"></el-input>
                    </el-form-item>

                    <el-form-item>
                        <el-button type="primary" @click="check">查找</el-button>
                    </el-form-item>

                    <el-form-item label="合同模板内容">
                        <el-input type="textarea" v-model="template.contractTemplateContent" placeholder="请输入内容"
                            maxlength="20000" show-word-limit rows="10">
                        </el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="addT">提 交</el-button>
                        <el-button type="success" @click="addM" :disabled="disabled">下一步</el-button>
                    </el-form-item>
                </el-form>
            </el-col>

        </el-row>
    </el-row>
</template>

<script>
export default {
    data() {
        return {
            productName: this.$route.params.name,
            template: {},
            product: {},
            disabled: true
        };
    },
    methods: {
        addM() {
            this.$router.push({
                name: 'AddDocumentType',
                params: {
                    id: this.template.productId
                }
            })
        },
        addT() {

            this.$axios.post("contractTemplate/insertSelective", this.template).then((res) => {
                if (res.data.code == 200) {
                    alert("合同模板添加成功，请配置补充材料！");
                    this.disabled = false;
                }
            })
        },
        check() {
            this.$axios.get("/products/selByName/" + this.productName).then((res) => {
                this.product = res.data.data.product;
                this.template.productId = this.product.productId;
            });
        }

    },
    mounted() {

    }
};
</script>

<style>
.text {
    font-size: 14px;
}

.item {
    margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
    display: table;
    content: "";
}

.clearfix:after {
    clear: both
}


.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.avatar-uploader .el-upload:hover {
    border-color: #409EFF;
}

.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
}

.avatar {
    width: 178px;
    height: 178px;
    display: block;
}

.el1{
    margin-top: 30px;
}
</style>